import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

Item {
    id: handleLocationBack_ManualProcess
    width: 1760
    height: 630

    Component.onCompleted: {
        Cpp_PLC.read_Handle_Process_Hold();
    }

    property real fontSize: Cpp_Language.CurrentLanguage === 1 ? 40 : Cpp_Language.CurrentLanguage === 2 ? 25 : Cpp_Language.CurrentLanguage === 3 ? 25 : 40

    A_NumberKeyboard{
        id: handleLoationKeyboard
        isDirectOverwrite: false
    }

    Rectangle{      // 中间分割线
        anchors.horizontalCenter: parent.horizontalCenter
        color: "black"
        width: 3
        height: 320        
    }

    Column{
        anchors.horizontalCenter: handleLocationBack_ManualProcess.horizontalCenter
        anchors.top: handleLocationBack_ManualProcess.top
        anchors.topMargin: 20
        spacing: 10


        Item{
            width: 1700
            height: 90


            Item{
                anchors.left: parent.left
                anchors.verticalCenter: parent.verticalCenter
                width: 800
                height: 90
                visible: !Cpp_PLC.M_394

                Rectangle{
                    width: 200
                    height: 80
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    color: "transparent"

                    Text{
                        anchors.centerIn: parent
                        font.pixelSize: fontSize
                        font.bold: true
                        text: qsTr("料  高")
                    }

                }

                A_NumberInput{
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: 250
                    inputWidth: 300
                    inputHeight: 80
                    keyboard: handleLoationKeyboard
                    text: Cpp_PLC.MaterialHeight_NormalProcess

                    onEditingFinished: function(value){
                        Cpp_PLC.write_into_PLC_32_Hold(214,value)
                    }
                }

                // A_Button{
                //     anchors.verticalCenter: parent.verticalCenter
                //     anchors.left: parent.left
                //     anchors.leftMargin: 600
                //     buttonWidth: 200
                //     buttonHeight: 80
                //     contentText_Data: qsTr("选择料高")
                // }

            }


            Item{
                anchors.right: parent.right
                anchors.verticalCenter: parent.verticalCenter
                width: 800
                height: 90

                Rectangle{
                    width: 200
                    height: 80
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: 20
                    color: "transparent"

                    Text{
                        anchors.centerIn: parent
                        font.pixelSize: fontSize
                        font.bold: true
                        text: qsTr("把 手 位 置")
                    }

                }

                A_NumberInput{
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.leftMargin: 270
                    inputWidth: 300
                    inputHeight: 80
                    keyboard: handleLoationKeyboard
                    text: Cpp_PLC.Handle_Location

                    onEditingFinished: function(value){
                        Cpp_PLC.write_into_PLC_32_Hold(282,value)
                    }
                }

            }



        }
        Item{
            width: 1700
            height: 90

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                // anchors.leftMargin: 200
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("料  长")
                }

            }

            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 250
                inputWidth: 300
                inputHeight: 80
                keyboard: handleLoationKeyboard
                text: Cpp_PLC.MaterialLength_NormalProcess

                onEditingFinished: function(value){
                    // console.log(value)
                    Cpp_PLC.write_into_PLC_32_Hold(212,value)
                }
            }


            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 920
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("把手位置补偿")
                }

            }

            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 1170
                inputWidth: 300
                inputHeight: 80
                keyboard: handleLoationKeyboard
                text: Cpp_PLC.Handle_Location_Compensate

                onEditingFinished: function(value){
                    Cpp_PLC.write_into_PLC_32_Hold(378,value)
                }
            }

        }
        Item{
            width: 1700
            height: 90

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                // anchors.leftMargin: 200
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("设 定 段 数")
                }

            }

            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 250
                inputWidth: 300
                inputHeight: 80
                keyboard: handleLoationKeyboard
                text: Cpp_PLC.CutSegments_NormalProcess

                onEditingFinished: function(value){
                    // console.log(value)
                    Cpp_PLC.write_into_PLC_16_Hold(230,value)
                }
            }

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 920
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("把 手 宽 度")
                }

            }

            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 1170
                inputWidth: 300
                inputHeight: 80
                keyboard: handleLoationKeyboard
                text: Cpp_PLC.Handle_Width

                onEditingFinished: function(value){
                    Cpp_PLC.write_into_PLC_32_Hold(284,value)
                }
            }

        }
        Item{
            width: 1700
            height: 90

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 450
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("当 前 段 数")
                }

            }

            Rectangle{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 700
                width: 300
                height: 80
                border.width: 3
                radius: 5
                border.color: "white"
                color: "black"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    color: "white"
                    text: Cpp_PLC.CurrentCutSegments_NormalProcess
                }

            }

            A_Button{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 1050
                buttonWidth: 200
                buttonHeight: 80
                contentText_Data: qsTr("清  空")
            }

        }

        Item{
            width: 1700
            height: 90

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 450
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("料 高 测 量 值")
                }

            }

            Rectangle{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 700
                width: 300
                height: 80
                border.width: 3
                radius: 5
                border.color: "white"
                color: "black"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    color: "white"
                    text: Cpp_PLC.MaterialHeightObserveValue
                }

            }

            A_Button{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 1050
                buttonWidth: 200
                buttonHeight: 80
                contentText_Data: qsTr("测  高")
            }

            A_Button{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 1300
                buttonWidth: 200
                buttonHeight: 80
                contentText_Data: qsTr("误差修正")
            }

        }

    }


    Rectangle{
        width: 1700
        height: 1
        color: "black"
        anchors.horizontalCenter: handleLocationBack_ManualProcess.horizontalCenter
        anchors.bottom: handleLocationBack_ManualProcess.bottom
        anchors.bottomMargin: 100
    }

    Rectangle{      // 普通加工 - 手动操作按钮
        anchors.horizontalCenter: handleLocationBack_ManualProcess.horizontalCenter
        anchors.bottom: handleLocationBack_ManualProcess.bottom
        anchors.bottomMargin: 10
        width: 1750
        height: 80
        color: "transparent"

        Row{
            anchors.centerIn: parent
            spacing: 30

            A_Button{
                buttonWidth: 150
                buttonHeight: 80
                contentText_Data: qsTr("压 紧")                
                isSelected: Cpp_PLC.M_239

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(236,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(236,false)
            }
            A_Button{
                buttonWidth: 150
                buttonHeight: 80
                contentText_Data: qsTr("左 压 紧")
                isSelected: Cpp_PLC.Y12

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(19,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(19,false)
            }
            A_Button{
                buttonWidth: 150
                buttonHeight: 80
                contentText_Data: qsTr("定 位")

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(24,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(24,false)
            }
            A_Button{
                buttonWidth: 150
                buttonHeight: 80
                contentText_Data: qsTr("锯 启")
                isSelected: Cpp_PLC.M_240

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(237,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(237,false)
            }
            A_Button{
                buttonWidth: 150
                buttonHeight: 80
                contentText_Data: qsTr("锯 切")
                isSelected: Cpp_PLC.M_241

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(238,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(238,false)
            }
            A_Button{
                buttonWidth: 150
                buttonHeight: 80
                contentText_Data: qsTr("复 位")

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(5,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(5,false)
            }

        }

    }


}
